﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;


namespace Wayloop.Blog.Core.Data.Entities
{
    [Bind(Exclude = "Post, CreatedOn, Status")]
    public class Comment : AbstractEntity
    {
        /// <summary>
        /// Gets or sets the post that this instance belongs to.
        /// </summary>
        /// <value>The post.</value>
        [Required]
        public virtual Post Post { get; set; }


        /// <summary>
        /// Gets or sets the name of the comment author.
        /// </summary>
        /// <value>The name of the comment author.</value>
        [Required]
        public virtual string AuthorName { get; set; }


        /// <summary>
        /// Gets or sets the website URL of the comment author.
        /// </summary>
        /// <value>The website URL of the comment author.</value>
        public virtual string AuthorWebsite { get; set; }


        /// <summary>
        /// Gets or sets the body.
        /// </summary>
        /// <value>The body.</value>
        [Required]
        public virtual string Body { get; set; }


        /// <summary>
        /// Gets or sets the "created on" timestamp.
        /// </summary>
        /// <value>The "created on" timestamp.</value>
        public virtual DateTime CreatedOn { get; set; }


        /// <summary>
        /// Gets or sets the status.
        /// </summary>
        /// <value>The status.</value>
        public virtual CommentStatus Status { get; set; }


        /// <summary>
        /// Gets the model signature.
        /// </summary>
        /// <returns>
        /// An array of property values that make up the "signature" of the model.
        /// </returns>
        protected override object[] GetEntitySignature()
        {
            return new object[] {
                (Post != null) ? Post.Id : 0,
                AuthorName,
                AuthorWebsite,
                Body,
                CreatedOn,
                Status,
            };
        }
    }
}